import request from '@/utils/request.js';

// 获取验证码
const GETUSERCODE_URL = '/sms/send/';
// 用户登录接口
const USERLOGIN_URL = '/user/login';
//获取微信扫码登录需要参数
const WXLOGIN_URL = '/user/weixin/getLoginParam/';
//提交订单,获取订单号码接口
const SUBMITORDER_URL = '/order/orderInfo/auth/submitOrder/';
//获取订单详情的数据
const GETORDERINFO_URL = '/order/orderInfo/auth/getOrderInfo/';
//取消订单的接口
const ORDERCANCEL_URL = '/order/orderInfo/auth/cancelOrder/';
//获取支付订单二维码接口(下单生成二维码)
const QRCODE_URL = '/order/weixin/createNative/';
// 微信支付，支付回调接口
const PAYCALLBACK_URL = '/order/weixin/notify';
//查询订单支付的结果(查询支付结果)
const PAYRESULT_URL = '/order/weixin/queryPayStatus/';
//获取当前账号用户信息
const USERINFO_URL = '/user/auth/getUserInfo';
//获取证件的类型的接口地址
const CERTIFICATIONTYPE_URL = '/cmn/dict/findByDictCode/';
//用户认证的结构
const USERCERTATION_URL = '/user/auth/userAuah';
//获取用户订单号的数据
const USERORDERINFO_URL = '/order/orderInfo/auth/';
//获取全部就诊人的信息
const ALLUSER_URL = '/user/patient/auth/findAll';
//获取订单的状态
const ORDERSTATE_URL = '/order/orderInfo/auth/getStatusList';
//获取城市的数据
const CITY_URL = '/cmn/dict/findByParentId/';
//新增就诊人接口
const ADDUSER_URL = '/user/patient/auth/save';
//更新已有的就诊人接口
const UPDATEUSER_URL = '/user/patient/auth/update';
//删除已有的就诊人
const DELETEUSER_URL = '/user/patient/auth/remove/'

// 获取验证码
export const reqCode = (phone) => {
    if (typeof phone !== 'number')
        return request.get(GETUSERCODE_URL + phone);
};
// 用户登录接口
export const reqUSerLogin = (data) => {
    return request.post(USERLOGIN_URL, data);
};
// 获取微信扫码登录需要参数
export const reqWxLogin = (wxRedirectUri) => {
    return request.get(
        WXLOGIN_URL + `?wxRedirectUri=${wxRedirectUri}`
    )
}

// 提交订单,获取订单号码接口
export const reqSubmitOrder = (hoscode,scheduleId,patientId) => {
  return request.post(SUBMITORDER_URL + `${hoscode}/${scheduleId}/${patientId}`);
}
//获取订单详情的数据
export const reqOrderInfo = (id) => {
  return request.get(GETORDERINFO_URL + id);
}
// 取消订单的接口
export const reqCancelOrder = (id) => {
  return request.get(ORDERCANCEL_URL + id);
}
// 获取支付订单二维码接口(下单生成二维码)
export const reqQrcode = (orderId) => {
  return request.get(QRCODE_URL + orderId);
}

// 微信支付，支付回调接口
export const reqPayCallback = (data) => {
  return request.post(PAYCALLBACK_URL, data);
}
// 查询订单支付的结果(查询支付结果)
export const reqQueryPayState = (orderId) => {
  return request.get(PAYRESULT_URL + orderId);
}
// 获取当前账号用户信息
export const reqUserInfo = () => {
  return request.get(USERINFO_URL);
}
// 获取证件的类型的接口地址
export const reqCertationType = (CertificatesType = 'CertificatesType') => {
  return request.get(CERTIFICATIONTYPE_URL + CertificatesType);
}
//用户认证接口
export const reqUserCertation = (data) => {
  return request.post(USERCERTATION_URL, data);
}
// 获取用户订单数据
export const reqUserOrderInfo = (page, limit, patientId, orderStatus) => {
  return request.get(USERORDERINFO_URL + `${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`);
}
// 获取全部就诊人的信息
export const reqAllUser = () => {
  return request.get(ALLUSER_URL);
}
// 获取全部订单的状态
export const reqOrderState = () => {
  return request.get(ORDERSTATE_URL);
}
// 获取城市的数据
export const reqCity = (parentId) => {
  return request.get(CITY_URL + parentId);
}
// 新增与修改已有的就诊人接口方法
export const reqAddOrUpdateUser = (data) => {
  if (data.id) {
    return request.put(UPDATEUSER_URL, data);
  } else {
    return request.post(ADDUSER_URL, data);
  }
}
// 删除已有的就诊人
export const reqRemoveUser = (id) => {
  return request.delete(DELETEUSER_URL + id);
}
